package Internect;


import java.io.*;

public class AdminManager {
    // 查找所有会员信息
    public void findAllMembers() {
        try {
            // 读取会员信息文件
            File file = new File("member_info.txt");
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line = null;

            // 输出所有会员信息
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

            reader.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // 查找会员
    public void findMember(String name) {
        try {
            // 读取会员信息文件
            File file = new File("member_info.txt");
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line = null;
            boolean found = false;

            // 查找对应的会员信息
            while ((line = reader.readLine()) != null) {
                String[] parts = line.split(",");
                if (parts[0].equals(name)) {
                    System.out.println(line);
                    found = true;
                    break;
                }
            }

            reader.close();

            if (!found) {
                System.out.println("Member not found.");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // 查看会员注销记录
    public void viewCancellationRecords() {
        try {
            // 读取会员注销记录文件
            File file = new File("cancellation_records.txt");
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line = null;

            // 输出所有会员注销记录
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

            reader.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
